package doc.ic.walkmore.DAO;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class MySQLiteHelper extends SQLiteOpenHelper {

	  public static final String TABLE_STEPS = "steps";
	  public static final String COLUMN_ID = "_id";
	  public static final String COLUMN_NUMBER = "number"; // Number of steps
	  public static final String COLUMN_TIME = "time"; // Duration in ms
	  public static final String COLUMN_ACTIVITY = "activity"; 
	  public static final String COLUMN_DISTANCE = "distance"; // Distance in cm
	  public static final String COLUMN_DATE = "date"; // Text string "YYYY-MM-DD HH:mm:ss"

	  private static final String DATABASE_NAME = "steps.db";
	  private static final int DATABASE_VERSION = 1;

	  // Database creation sql statement
	  private static final String DATABASE_CREATE = "create table "
	      + TABLE_STEPS + "(" + COLUMN_ID + " integer primary key autoincrement, "
			  + COLUMN_NUMBER + " integer not null, "
			  + COLUMN_TIME + " integer not null, "
			  + COLUMN_ACTIVITY + " text not null, "
			  + COLUMN_DISTANCE + " integer not null, "
			  + COLUMN_DATE + " text not null);";

	  public MySQLiteHelper(Context context) {
	    super(context, DATABASE_NAME, null, DATABASE_VERSION);
	  }

	  @Override
	  public void onCreate(SQLiteDatabase database) {
	    database.execSQL(DATABASE_CREATE);
	  }

	  @Override
	  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	    Log.w(MySQLiteHelper.class.getName(),
	        "Upgrading database from version " + oldVersion + " to "
	            + newVersion + ", which will destroy all old data");
	    db.execSQL("DROP TABLE IF EXISTS " + TABLE_STEPS);
	    onCreate(db);
	  }

	} 